<template>
    <div class="counter">
        <p>counter!! ==> {{$store.state.counter}}</p>
        <p @click="clickme">点击变成100</p>
        <p><button @click="increment">counter++</button></p>
    </div>
</template>

<script>
import {mapMutations} from "vuex"
import axios from "axios"
export default {
    methods:{
        ...mapMutations(["increment"]),
        async clickme(){
            let {data} = await axios.get("/api/good.json");
            this.$store.commit("changeCount",data.price)
        }
    },
    // async fetch({store}){ //设置vuex里面的状态   asyncData用来设置组件的数据
    //     let {data} = await axios.get("/api/good.json");
    //     store.commit("changeCount",data.price)
    // }
}
</script>

<style>

</style>
